<?php

/**
 * This is the model class for table "family_history".
 *
 * The followings are the available columns in table 'family_history':
 * @property integer $id
 * @property string $blindness
 * @property string $blindness_relate
 * @property string $cataracts
 * @property string $cataracts_relate
 * @property string $crosseyes
 * @property string $croseyes_relate
 * @property string $galucoma
 * @property string $galucoma_relate
 * @property string $macular_degeneration
 * @property string $macula_degenerationr_relate
 * @property string $retinal_disease
 * @property string $retinal_disease_relate
 * @property string $arthiritis
 * @property string $arthiritis_relate
 * @property string $cancer
 * @property string $cancer_specify
 * @property string $cancer_relate
 * @property string $diabetes
 * @property string $diabetes_relate
 * @property string $heart_disease
 * @property string $heart_relate
 * @property string $high_blood_pressure
 * @property string $high_blood_pressure_relate
 * @property string $kidney
 * @property string $kidney_relate
 * @property string $lupus
 * @property string $lupus_relate
 * @property string $thyroid
 * @property string $thyroid_relate
 * @property string $others
 * @property string $others_specify
 * @property string $others_relate
 * @property integer $personalinfo_id
 *
 * The followings are the available model relations:
 * @property PersonalInformation $personalinfo
 */
class FamilyHistory extends CActiveRecord
{
	/**
	 * Returns the static model of the specified AR class.
	 * @param string $className active record class name.
	 * @return FamilyHistory the static model class
	 */
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}

	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return 'family_history';
	}

	/**
	 * @return array validation rules for model attributes.
	 */
	public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		return array(
			array('personalinfo_id', 'required'),
			array('personalinfo_id', 'numerical', 'integerOnly'=>true),
			array('blindness, cataracts, crosseyes, galucoma, macular_degeneration, retinal_disease, arthiritis, cancer, diabetes, heart_disease, high_blood_pressure, kidney, lupus, thyroid, others', 'length', 'max'=>5),
			array('blindness_relate, cataracts_relate, croseyes_relate, galucoma_relate, macula_degenerationr_relate, retinal_disease_relate, arthiritis_relate, cancer_relate, diabetes_relate, heart_relate, high_blood_pressure_relate, kidney_relate, lupus_relate, thyroid_relate, others_specify, others_relate', 'length', 'max'=>100),
			array('cancer_specify', 'length', 'max'=>45),
			// The following rule is used by search().
			// Please remove those attributes that should not be searched.
			array('id, blindness, blindness_relate, cataracts, cataracts_relate, crosseyes, croseyes_relate, galucoma, galucoma_relate, macular_degeneration, macula_degenerationr_relate, retinal_disease, retinal_disease_relate, arthiritis, arthiritis_relate, cancer, cancer_specify, cancer_relate, diabetes, diabetes_relate, heart_disease, heart_relate, high_blood_pressure, high_blood_pressure_relate, kidney, kidney_relate, lupus, lupus_relate, thyroid, thyroid_relate, others, others_specify, others_relate, personalinfo_id', 'safe', 'on'=>'search'),
		);
	}

	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
		// NOTE: you may need to adjust the relation name and the related
		// class name for the relations automatically generated below.
		return array(
			'personalinfo' => array(self::BELONGS_TO, 'PersonalInformation', 'personalinfo_id'),
		);
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'id' => 'ID',
			'blindness' => 'Blindness',
			'blindness_relate' => 'Blindness Relate',
			'cataracts' => 'Cataracts',
			'cataracts_relate' => 'Cataracts Relate',
			'crosseyes' => 'Crosseyes',
			'croseyes_relate' => 'Croseyes Relate',
			'galucoma' => 'Galucoma',
			'galucoma_relate' => 'Galucoma Relate',
			'macular_degeneration' => 'Macular Degeneration',
			'macula_degenerationr_relate' => 'Macula Degenerationr Relate',
			'retinal_disease' => 'Retinal Disease',
			'retinal_disease_relate' => 'Retinal Disease Relate',
			'arthiritis' => 'Arthiritis',
			'arthiritis_relate' => 'Arthiritis Relate',
			'cancer' => 'Cancer',
			'cancer_specify' => 'Cancer Specify',
			'cancer_relate' => 'Cancer Relate',
			'diabetes' => 'Diabetes',
			'diabetes_relate' => 'Diabetes Relate',
			'heart_disease' => 'Heart Disease',
			'heart_relate' => 'Heart Relate',
			'high_blood_pressure' => 'High Blood Pressure',
			'high_blood_pressure_relate' => 'High Blood Pressure Relate',
			'kidney' => 'Kidney',
			'kidney_relate' => 'Kidney Relate',
			'lupus' => 'Lupus',
			'lupus_relate' => 'Lupus Relate',
			'thyroid' => 'Thyroid',
			'thyroid_relate' => 'Thyroid Relate',
			'others' => 'Others',
			'others_specify' => 'Others Specify',
			'others_relate' => 'Others Relate',
			'personalinfo_id' => 'Personalinfo',
		);
	}

	/**
	 * Retrieves a list of models based on the current search/filter conditions.
	 * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
	 */
	public function search()
	{
		// Warning: Please modify the following code to remove attributes that
		// should not be searched.

		$criteria=new CDbCriteria;

		$criteria->compare('id',$this->id);
		$criteria->compare('blindness',$this->blindness,true);
		$criteria->compare('blindness_relate',$this->blindness_relate,true);
		$criteria->compare('cataracts',$this->cataracts,true);
		$criteria->compare('cataracts_relate',$this->cataracts_relate,true);
		$criteria->compare('crosseyes',$this->crosseyes,true);
		$criteria->compare('croseyes_relate',$this->croseyes_relate,true);
		$criteria->compare('galucoma',$this->galucoma,true);
		$criteria->compare('galucoma_relate',$this->galucoma_relate,true);
		$criteria->compare('macular_degeneration',$this->macular_degeneration,true);
		$criteria->compare('macula_degenerationr_relate',$this->macula_degenerationr_relate,true);
		$criteria->compare('retinal_disease',$this->retinal_disease,true);
		$criteria->compare('retinal_disease_relate',$this->retinal_disease_relate,true);
		$criteria->compare('arthiritis',$this->arthiritis,true);
		$criteria->compare('arthiritis_relate',$this->arthiritis_relate,true);
		$criteria->compare('cancer',$this->cancer,true);
		$criteria->compare('cancer_specify',$this->cancer_specify,true);
		$criteria->compare('cancer_relate',$this->cancer_relate,true);
		$criteria->compare('diabetes',$this->diabetes,true);
		$criteria->compare('diabetes_relate',$this->diabetes_relate,true);
		$criteria->compare('heart_disease',$this->heart_disease,true);
		$criteria->compare('heart_relate',$this->heart_relate,true);
		$criteria->compare('high_blood_pressure',$this->high_blood_pressure,true);
		$criteria->compare('high_blood_pressure_relate',$this->high_blood_pressure_relate,true);
		$criteria->compare('kidney',$this->kidney,true);
		$criteria->compare('kidney_relate',$this->kidney_relate,true);
		$criteria->compare('lupus',$this->lupus,true);
		$criteria->compare('lupus_relate',$this->lupus_relate,true);
		$criteria->compare('thyroid',$this->thyroid,true);
		$criteria->compare('thyroid_relate',$this->thyroid_relate,true);
		$criteria->compare('others',$this->others,true);
		$criteria->compare('others_specify',$this->others_specify,true);
		$criteria->compare('others_relate',$this->others_relate,true);
		$criteria->compare('personalinfo_id',$this->personalinfo_id);

		return new CActiveDataProvider($this, array(
			'criteria'=>$criteria,
		));
	}
	public function getFName()
        {       
        return $this->personal_information['FullName']; 
        }
}